<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 50px;
            height: 50px;
            margin-top: 15px;
            border:1px #ccc solid
        }
        .one{
            background-color: royalblue;
        }
        .two{
            background-color: seagreen;
        }
        .three{
            background-color: chocolate;
        }
    </style>
</head>
<body>
       <div class="one"></div>
       <div class='two'></div>
       <div class="three"></div>
</body>
</html>
<script src='./lib/jquery.min.js'></script>
<script>
    $(()=>{
        //1 记录当前body的背景色
       let currentcolor= $('body').css("background-color");  
       $("div").mouseover(function(){
        $("body").css({"background-color":$(this).css("background-color")})
       }).mouseout(function(){
        $("body").css({"background-color":currentcolor});
       }).click(function(){
        $("body").css({"background-color":$(this).css("background-color")})
        //重置当前背景色
        currentcolor = $(this).css("background-color");
    });
    });
</script>